<template>
      <div>
            <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" :ellipsis="false"
                  @select="handleSelect">
                  <div class="mg flex" @click="getChildCollapseIsOpen()">
                        <el-icon color="#000" size="26" class="no-inherit">
                              <Expand v-if="data.menuCollapseIsOpen" />
                              <Fold v-else/>
                        </el-icon>
                  </div>
                  <div class="flex-grow" />
                  <el-menu-item index="1">Processing Center</el-menu-item>
                  <el-sub-menu index="2">
                        <template #title>Workspace</template>
                        <el-menu-item index="2-1">item one</el-menu-item>
                        <el-menu-item index="2-2">item two</el-menu-item>
                        <el-menu-item index="2-3">item three</el-menu-item>
                        <el-sub-menu index="2-4">
                              <template #title>item four</template>
                              <el-menu-item index="2-4-1">item one</el-menu-item>
                              <el-menu-item index="2-4-2">item two</el-menu-item>
                              <el-menu-item index="2-4-3">item three</el-menu-item>
                        </el-sub-menu>
                  </el-sub-menu>
            </el-menu>
      </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'
import {
      Expand,
      Fold
} from '@element-plus/icons-vue'

const activeIndex = ref('1')
const handleSelect = (key: string, keyPath: string[]) => {
      console.log(key, keyPath)
}

let data = reactive({
      menuCollapseIsOpen: false
})

const emit = defineEmits(['getHeadMenuCollapse'])
const getChildCollapseIsOpen = () => {
      data.menuCollapseIsOpen = !data.menuCollapseIsOpen
    emit('getHeadMenuCollapse', data.menuCollapseIsOpen)
}

</script>

<style>
.flex-grow {
      flex-grow: 1;
}
.el-menu-demo {
      height: 50px;
}
.mg {
      margin: 10px;
}
</style>